import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'

/*解决路由冗余*/
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [{
        path: '/Login',
        name: 'Login',
        component: Login,
        meta: {
            isNeedLogin: false,
        }
    },
    /*第一级路由===》到Home页面*/
    {

        path: '/Home',
        name: 'Home',
        component: () =>
            import ('../views/Home.vue'),
        redirect: { name: 'Homemin' },
        meta: {
            isNeedLogin: true,
        },
        /*表示进入Home页面的同时也进入Homemin页面*/
        /*第二级路由===》到Homemin页面 同时默认直接进工作台页面*/
        children: [{
                path: '/Home/Homemin',
                name: 'Homemin',
                component: () =>
                    import ('../views/Homemin'),
                redirect: '/Home/Homemin/Workbench',
                meta: {
                    isNeedLogin: true,
                },
                /*同时默认直接进工作台页面*/
                /*第三级路由===》到Homemin下面的需要显示的相应页面*/
                children: [
                    /*我的 == 工作台 我的部门  个人资料*/
                    {
                        path: '/Home/Homemin/Workbench',
                        name: 'Workbench',
                        component: () =>
                            import ('../views/Workbench.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/Mydepartment',
                        name: 'Mydepartment',
                        component: () =>
                            import ('../views/Mydepartment.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/Predata',
                        name: 'Predata',
                        component: () =>
                            import ('../views/Predata.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    /*新房 == 发布楼盘 楼盘管理 淘优惠 咨询导购 买房管家*/
                    {
                        path: '/Home/Homemin/ReleaseProperty',
                        name: '发布楼盘',
                        component: () =>
                            import ('../views/ReleaseProperty.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/RealEstateManagement',
                        name: '楼盘管理',
                        component: () =>
                            import ('../views/RealEstateManagement.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    { /*楼盘管理下的=====楼盘管理下拉菜单*/
                        path: '/HouseAdmin',
                        name: 'HouseAdmin',
                        component: () =>
                            import ('../views/HouseAdmin'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/Preferential',
                        name: '淘优惠',
                        component: () =>
                            import ('../views/Preferential.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/Guide',
                        name: '咨询导购',
                        component: () =>
                            import ('../views/Guide.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/ZxHousingManager',
                        name: 'ZxHousingManager',
                        component: () =>
                            import ('../views/ZxHousingManager'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    { /*买房管家下的===详情*/
                        path: '/Home/Homemin/Information',
                        name: 'Information',
                        component: () =>
                            import ('../views/ZxInformation'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    { /*买房管家下的===楼盘测评===发布测评*/
                        path: '/Home/Homemin/ZxReleaseHouseTest',
                        name: 'ZxReleaseHouseTest',
                        component: () =>
                            import ('../views/ZxReleaseHouseTest'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    /*交易 == 订单管理 退款管理 结算统计 代下订单*/
                    {
                        path: '/Home/Homemin/OrderManage',
                        name: '订单管理',
                        component: () =>
                            import ('../views/OrderManage.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    { /*订单管理下的===详情OrderDetails*/
                        path: '/Home/Homemin/OrderDetails',
                        name: 'OrderDetails',
                        component: () =>
                            import ('../views/OrderDetails'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    { /*订单管理下的===CollectionDetails*/
                        path: '/Home/Homemin/CollectionDetails',
                        name: 'CollectionDetails',
                        component: () =>
                            import ('../views/CollectionDetails'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/Refund',
                        name: '退款管理',
                        component: () =>
                            import ('../views/Refund.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/Statistical',
                        name: '统计结算',
                        component: () =>
                            import ('../views/Statistical.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/Replace',
                        name: '代下订单',
                        component: () =>
                            import ('../views/Replace.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    /*会员 ==== 会员管理*/
                    {
                        path: '/Home/Homemin/Member',
                        name: '会员管理',
                        component: () =>
                            import ('../views/Member.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    /*设置 ==== 权限设置  运营配置 个人资料*/
                    {
                        path: '/Home/Homemin/Permissions',
                        name: '权限设置',
                        component: () =>
                            import ('../views/Permissions.vue'),
                        meta: {
                            isNeedLogin: true,
                        },

                    },
                    { /*权限设置===跳转页面*/
                        path: '/Home/Homemin/Administrator',
                        name: 'Administrator',
                        component: () =>
                            import ('../views/Administrator.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/Department',
                        name: 'Department',
                        component: () =>
                            import ('../views/Department.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/Role',
                        name: 'Role',
                        component: () =>
                            import ('../views/Role.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/UpdateRole',
                        name: 'UpdateRole',
                        component: () =>
                            import ('../views/UpdateRole.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/UpdateAdmin',
                        name: 'UpdateAdmin',
                        component: () =>
                            import ('../views/UpdateAdmin.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/SystemConfig',
                        name: '运营配置',
                        component: () =>
                            import ('../views/SystemConfig.vue'),
                        meta: {
                            isNeedLogin: true,
                        },
                    },
                    {
                        path: '/Home/Homemin/Statement',
                        name: '个人资料',
                        component: () =>
                            import ('../views/Statement.vue'),
                        meta: {
                            isNeedLogin: true,
                        },

                    },
                ]
            },



        ]
    },
    {
        path: '/',
        redirect: ('/Login')
    }
]


const router = new VueRouter({
    routes
})

export default router